import Axios from 'axios'

export default (url,data,type = 'GET') => {

  return new Promise((resolve, reject) => {

    let promise = null
    if(type == 'POST'){
      promise = Axios({
        url,
        data,
        method:type
      }) 
    }
    else {
      promise = Axios({
        url,
        params:data
      })
    }
    promise.then(res => {
      resolve(res.data)
    })
    .catch(err => {
      console.log('出错了')
    })
  })
}